package com.eureka.client.demo.lancher;

import io.jmnarloch.spring.cloud.ribbon.support.RibbonFilterContextHolder;
import org.apache.commons.lang3.StringUtils;


public abstract class ServiceLancherHandler {
    protected boolean handle(String serviceId) {
        String serviceLancher = getServiceLancher(serviceId);
        if (StringUtils.isEmpty(serviceLancher)){
            return false;
        }
        RibbonFilterContextHolder.clearCurrentContext();
        RibbonFilterContextHolder.getCurrentContext()
                .add("lancher", serviceLancher);
        return true;
    }

    abstract String getServiceLancher(String serviceId);
}
